﻿using Spring.Objects.Factory.Config;
using Spring.Objects.Factory.Support;

namespace FluentSpring.Test.Utils
{
    public class TestUtil
    {
        public static IObjectDefinition BuildObjectDefinition(ConfigContext configContext)
        {

            IObjectDefinitionFactory objectDefinitionFactory = new DefaultObjectDefinitionFactory();
            ObjectDefinitionBuilder builder =
                ObjectDefinitionBuilder.RootObjectDefinition(objectDefinitionFactory, configContext.RegisteredType);

            foreach (BuilderAction action in configContext.BuilderActionList)
            { action(builder); }

            return builder.ObjectDefinition;
        }
    }
}
